package com.openbravo.data.gui;

import java.awt.Container;
import java.awt.Dimension;
import java.awt.FlowLayout;
import java.awt.Frame;
import java.awt.Toolkit;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.List;
import javax.swing.AbstractListModel;
import javax.swing.JButton;
import javax.swing.JDialog;
import javax.swing.JList;
import javax.swing.JPanel;
import javax.swing.JRootPane;
import javax.swing.JScrollPane;
import javax.swing.JToolBar;
import javax.swing.ListModel;

public class JListData extends JDialog
{
  private Object m_selected;
  private JButton jButton1;
  private JButton jButton2;
  private JPanel jPanel1;
  private JScrollPane jScrollPane1;
  private JToolBar jToolBar1;
  private JButton m_jCancel;
  private JList m_jData;
  private JButton m_jOK;

  public JListData(Frame paramFrame)
  {
    super(paramFrame, true);
    initComponents();
    getRootPane().setDefaultButton(this.m_jOK);
  }

  public Object showList(List paramList)
  {
    return showList(new MyListData(paramList));
  }

  public Object showList(ListModel paramListModel)
  {
    this.m_jData.setModel(paramListModel);
    this.m_selected = null;
    setVisible(true);
    return this.m_selected;
  }

  private void initComponents()
  {
    this.jPanel1 = new JPanel();
    this.m_jOK = new JButton();
    this.m_jCancel = new JButton();
    this.jScrollPane1 = new JScrollPane();
    this.m_jData = new JList();
    this.jToolBar1 = new JToolBar();
    this.jButton1 = new JButton();
    this.jButton2 = new JButton();
    setDefaultCloseOperation(2);
    this.jPanel1.setLayout(new FlowLayout(2));
    this.m_jOK.setText("Aceptar");
    this.m_jOK.addActionListener(new ActionListener()
    {
      public void actionPerformed(ActionEvent paramActionEvent)
      {
        JListData.this.m_jOKActionPerformed(paramActionEvent);
      }
    });
    this.jPanel1.add(this.m_jOK);
    this.m_jCancel.setText("Cancelar");
    this.m_jCancel.addActionListener(new ActionListener()
    {
      public void actionPerformed(ActionEvent paramActionEvent)
      {
        JListData.this.m_jCancelActionPerformed(paramActionEvent);
      }
    });
    this.jPanel1.add(this.m_jCancel);
    getContentPane().add(this.jPanel1, "South");
    this.m_jData.setSelectionMode(0);
    this.jScrollPane1.setViewportView(this.m_jData);
    getContentPane().add(this.jScrollPane1, "Center");
    this.jToolBar1.setFloatable(false);
    this.jButton1.setText("jButton1");
    this.jToolBar1.add(this.jButton1);
    this.jButton2.setText("jButton2");
    this.jToolBar1.add(this.jButton2);
    getContentPane().add(this.jToolBar1, "North");
    Dimension localDimension = Toolkit.getDefaultToolkit().getScreenSize();
    setBounds((localDimension.width - 264) / 2, (localDimension.height - 337) / 2, 264, 337);
  }

  private void m_jCancelActionPerformed(ActionEvent paramActionEvent)
  {
    dispose();
  }

  private void m_jOKActionPerformed(ActionEvent paramActionEvent)
  {
    this.m_selected = this.m_jData.getSelectedValue();
    dispose();
  }

  private static class MyListData extends AbstractListModel
  {
    private List m_data;

    public MyListData(List paramList)
    {
      this.m_data = paramList;
    }

    public Object getElementAt(int paramInt)
    {
      return this.m_data.get(paramInt);
    }

    public int getSize()
    {
      return this.m_data.size();
    }
  }
}

/* Location:           D:\PowerFulPOS-2.30.2\openbravopos.jar
 * Qualified Name:     com.openbravo.data.gui.JListData
 * JD-Core Version:    0.6.0
 */